import baseView from '../../../../app/base/baseView';

const { ccclass } = cc._decorator;

interface onShow  { title?: string, mask?: boolean, success?: Function, fail?: Function, complete?: Function }

@ccclass
export default class roofLoading extends baseView {
    private count = 0;

    protected beforeShow(data, next) {
        this.count++;
        next(true);
    }

    protected onShow({ title, mask = true, success, fail, complete }: onShow = {}) {
        this.node.getComponent(cc.BlockInputEvents).enabled = !!mask;
        success && success();
        complete && complete();
    }

    protected beforeHide(data, next) {
        if (this.count > 0 && --this.count === 0) {
            next(true);
        } else {
            next(false);
        }
    }
}
